package com.demoworld.completablefuture;

import java.util.concurrent.CompletableFuture;

/**
 * Created by francis on 2017/6/19.
 */
public class Test {
    public static void main(String args[]) {
        CompletableFuture.supplyAsync(() -> {
            System.out.println("1");
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return 1;
        }).whenComplete((item, ex) -> {
            System.out.println("2");
        });


        CompletableFuture.supplyAsync(() -> {
            System.out.println("3");
            return 1;
        }).whenComplete((item, ex) -> {
            System.out.println("4");
        });

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
